package com.mall.web.controller.goods.app;

import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.core.page.TableDataInfo;
import com.mall.goods.model.dto.GoodsDto;
import com.mall.goods.model.vo.GoodsVo;
import com.mall.goods.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品Controller
 */
@RestController
@RequestMapping("/app/goods/goods")
public class AppGoodsController extends BaseController
{
    @Autowired
    private IGoodsService goodsService;

    /**
     * 查询商品列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GoodsDto goodsDto)
    {
        startPage();
        List<GoodsVo> list = goodsService.selectAppGoodsList(goodsDto);
        return getDataTable(list);
    }


    /**
     * 获取商品详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(goodsService.selectGoodsById(id));
    }

}
